package com.facebook.drawee.generic;

import android.annotation.SuppressLint;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import com.facebook.common.internal.VisibleForTesting;
import com.facebook.drawee.drawable.ForwardingDrawable;
import com.facebook.drawee.drawable.VisibilityAwareDrawable;
import com.facebook.drawee.drawable.VisibilityCallback;
import javax.annotation.Nullable;

public final class RootDrawable extends ForwardingDrawable implements VisibilityAwareDrawable {
    @VisibleForTesting
    @Nullable Drawable mControllerOverlay;
    @Nullable private VisibilityCallback mVisibilityCallback;

    public RootDrawable(Drawable arg1) {
        super(arg1);
    }

    public final void a(@Nullable VisibilityCallback arg1) {
        this.mVisibilityCallback = arg1;
    }

    @SuppressLint(value={"WrongCall"}) public final void draw(Canvas canvas) {
        if(this.isVisible()) {
            if(this.mVisibilityCallback != null) {
                this.mVisibilityCallback.onDraw();
            }

            super.draw(canvas);
        }
    }

    public final int getIntrinsicHeight() {
        return -1;
    }

    public final int getIntrinsicWidth() {
        return -1;
    }

    public final boolean setVisible(boolean visible, boolean restart) {
        if(this.mVisibilityCallback != null) {
            this.mVisibilityCallback.onVisibilityChange(visible);
        }

        return super.setVisible(visible, restart);
    }
}

